﻿using System.Windows.Controls;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using ScrumFactory.Composition.ViewModel;

namespace ScrumFactory.Composition.ViewModel {
   
    /// <summary>
    /// Base class for a basic Factory Panel ViewModel.
    /// </summary>    
    public class BasePanelViewModel {

        private bool isLoadingData = false;        
        private bool dataLoadedBefore = false;
        public event PropertyChangedEventHandler PropertyChanged;

        public virtual bool NeedRefresh { get; set; }

        /// <summary>
        /// Gets and Sets whenever the panel is retrieving data from the server.
        /// </summary>
        public bool IsLoadingData {
            get {
                return this.isLoadingData;
            }
            protected set {                
                isLoadingData = value;
                dataLoadedBefore = true;
                OnPropertyChanged("IsLoadingData");
            }
        }

        /// <summary>
        /// Gets whenever the data has already been loaded before.
        /// </summary>
        public bool DataLoadedBefore {
            get {
                return this.dataLoadedBefore;
            }
        }

        /// <summary>
        /// Called when a property has changed.
        /// </summary>
        /// <param name="property">The property.</param>
        protected void OnPropertyChanged(string property) {
            if (this.PropertyChanged != null) 
                this.PropertyChanged(this, new PropertyChangedEventArgs(property));            
        }
               
    }
}
